<template>
  <div class="pledeg">
    <x-header :left-options="{showBack: true, backText: ''}" style="">个人承诺</x-header>

    <group title="" class="group_first">
      <x-textarea :max="30" ref="pledge" name="pledge" v-model="pledge" placeholder="" autofocus></x-textarea>
    </group>

    <x-button type="primary" @click.native="submit()">完成</x-button>
  </div>
</template>


<script>
import { Group, XHeader, XTextarea, XButton } from "vux";
import { mapGetters } from "vuex";

export default {
  components: {
    Group,
    XHeader,
    XTextarea,
    XButton
  },
  data() {
    return {
      pledge: ""
    };
  },
  //计算属性
  computed: {
    ...mapGetters(["userInfo"]),
  },
  created() {
    this.pledge = this.userInfo.promise
  },
  methods: {
    submit() {
      const userid = window.localStorage.getItem("user");
      let userpromise = this.pledge;
      this.$store.dispatch("doPromise", { id: userid, promise: userpromise });
      this.$router.replace("/user/info");
    }
  }
};
</script>

<style lang="less">
.pledeg {
  .group_first {
    padding: 2.875rem 0 0;
  }
  .weui-btn {
    width: 340/16rem !important;
    margin-top: 10/16rem;
    background: rgb(214, 60, 50) !important;
  }
}
</style>
